STEP 7: Let's create a function for our battle scene!

  • Go to . Drag Define Function to the bottom of your program.
  • Change the function name to battle_scene.
  • Drop the Dragon into your scene at the position (150, -150). Change the sprite's name to dragon.
  • Have your knight Say "Oh no, a dragon!"

To navigate the page using the TAB key, first press ESC to exit the code editor.

sprite = codesters.Sprite("knight1", -175, -150) sprite.set_speed(2) def park_scene(): stage.set_background("park") sprite.say("I should hurry to the castle!") sprite.move_forward(550) park_scene() def bridge_scene(): stage.set_background("drawbridge") sprite.go_to(-175, -150) sprite.say("I made it!") stage.wait(2) bridge_scene()
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)